package org.jash.ting13.net

import android.graphics.Bitmap
import org.jash.ting13.entity.BookDetail
import org.jash.ting13.entity.HomeResult
import org.jash.ting13.entity.LoginResult
import org.jash.ting13.entity.PlayResult
import org.jash.ting13.entity.SearchResult
import retrofit2.Call
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import retrofit2.http.Url




interface APIService {
    @GET("/user/public/verify.html")
    suspend fun getVerify():Bitmap
    @POST("/user/public/login.html")
    @FormUrlEncoded
    suspend fun login(@Field("username") username:String, @Field("password") password:String, @Field("verify") verify:String): LoginResult
    @GET("https://m.ysts.cc/{url}")
    fun getPlay(@Path("url") url: String): PlayResult
    @POST("https://m.ysts.cc/api/act/play")
    @FormUrlEncoded
    fun getUrl(
        @Header("Sc") sc: String,
        @Header("St") sp: String,
        @Field("nid") nid: String,
        @Field("cid") cid: String,
        @Field("sort") sort: String
    ): String
    @GET("/")
    suspend fun getHome(): HomeResult
//    @GET("/search/{keyword}/lastupdate/{page}.html")
    @GET("/search.html?searchtype=name")
    suspend fun search(@Query("searchword") keyword:String, @Query("page") page:Int): SearchResult
    @GET
    suspend fun getDetail(@Url url:String, @Query("p") page: Int): BookDetail

}